﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IGGCore.Data
{
    public class Injuries
    {
        public List<Injury> TimeBasedInjuries { get; set; }
        public Dictionary<string, List<Injury>> TeamBasedInjuries { get; set; }

        public Injuries()
        {
            TimeBasedInjuries = new List<Injury>();
            TeamBasedInjuries = new Dictionary<string, List<Injury>>();
        }

        public void AddInjury(DateTime updated, string team, string name, string pos, string details, string ret)
        {
            Injury inj = new Injury();
            inj.Team = team;
            inj.Name = name;
            inj.Position = pos;
            inj.Details = details;
            inj.Return = ret;
            inj.LastUpdate = updated;

            TimeBasedInjuries.Add(inj);
            TimeBasedInjuries = TimeBasedInjuries.OrderByDescending(b => b.LastUpdate).ToList();

            if (TeamBasedInjuries.ContainsKey(team))
            {
                TeamBasedInjuries[team].Add(inj);
            }
            else
            {
                TeamBasedInjuries[team] = new List<Injury>();
                TeamBasedInjuries[team].Add(inj);
            }
            
        }
    }

    public class Injury
    {
        public DateTime LastUpdate { get; set; }
        public string Team { get; set; }
        public string Name { get; set; }
        public string Position { get; set; }
        public string Details { get; set; }
        public string Return { get; set; }
    }
}
